﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LogManager.Base.Data;
using LogManager.Base.Models;
using LogManager.Config.View;

namespace LogManager.Config.Data
{
    public class ViewConfigService : IViewService
    {
        private readonly IEnumerable<ViewConfiguration> _views;

        public ViewConfigService(ViewCollection viewCollection)
        {
            _views = viewCollection.Cast<ViewConfiguration>();
        }

        #region Implementation of IViewService

        public IEnumerable<IView> All()
        {
            return _views;
        }

        public IView Get(string name)
        {
            return _views.Where(v => v.Name == name).SingleOrDefault();
        }

        #endregion
    }
}
